-
Notifications
You must be signed in to change notification settings - Fork 141
perf(ai): Avoid a few std::vector copies when passing ai paths to functions #1895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf(ai): Avoid a few std::vector copies when passing ai paths to functions #1895
Conversation
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that the passed vector is never used after it is consumed?
Looking at call sites, they all pass local vectors (exitPath, path) that are not used after the function call. They go out of scope immediately, so this is safe, right? |
|
Yes, when the std::vector contents are not used anymore after they are now consumed by the functions then this is safe. |
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
Outdated
Show resolved
Hide resolved
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
Outdated
Show resolved
Hide resolved
e97db76 to
8c112de
Compare
Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
Outdated
Show resolved
Hide resolved
|
Still needs work here. |
…hange parameter to reference
e9b7e5c to
5965d08
Compare
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in principle. 2 more suggestions.
Refactors path-following functions to use move when transferring
std::vector<Coord3D>ownershipChanges:
aiFollowExitProductionPathandaiFollowPathinline functions to accept non-const vector pointers and usestd::moveAIStateMachine::setGoalPathto move the vector instead of copyingprivateFollowPathanddoQuickExitsignatures to support move semantics